from django import forms
from .models import ProductInventoryLog, MaterialInventoryLog

class ProductInboundForm(forms.ModelForm):
    class Meta:
        model = ProductInventoryLog
        fields = ['sku', 'box_spec', 'box_count', 'date', 'remark']
        widgets = {
            'remark': forms.Textarea(attrs={'rows': 1}),
        }

class MaterialInboundForm(forms.ModelForm):
    class Meta:
        model = MaterialInventoryLog
        fields = ['sku', 'pcs_count', 'date', 'remark']
        widgets = {
            'remark': forms.Textarea(attrs={'rows': 1}),
        }

class ProductOutboundForm(forms.Form):
    sku = forms.CharField(max_length=50, required=True)
    box_spec = forms.CharField(max_length=50, required=True)
    total_boxes = forms.IntegerField(required=True)
    outbound_boxes = forms.IntegerField(required=True, initial=0)
    date = forms.DateField(required=True)

class StockCalculationForm(forms.Form):
    product_sku = forms.ChoiceField(
        label="产品SKU",
        widget=forms.Select(attrs={'class': 'form-control sku-select'}))
    required_quantity = forms.IntegerField(
        label="需求数量",
        min_value=1,
        widget=forms.NumberInput(attrs={
            'class': 'form-control',
            'placeholder': '输入需求数量'
        }))
